<?php

namespace App\Handler\WeChat;

use App\Models\Hospital;

class TextHandler
{
    public function __invoke($message, \Closure $next)
    {
        if ($message->MsgType === 'text') {
            $str = strtolower(mb_substr($message->Content, 0, 2, 'utf-8'));
            switch ($str) {
                case 'sq':
                    $docName = substr($message->Content, 2);
                    $docName = urlencode($docName);

                    return "访问链接查看:".env('WECHAT_URL')."/doctors?search={$docName}";
                case "cx":
                    return $message->FromUserName;
            }
            if ($message->Content == '成人疫苗') {
                return "预约成人疫苗请进入“儿宝宝小程序”后点击下方菜单“预约”，选择社区后预约";
            }
            return "宝宝家长，您在社区医院遇到体检查看问题，疫苗预约、体检预约、健康指导等问题时。可以点击公众号底栏进入儿宝宝小程序，点击我的，找到在线客服帮您进行解答。";
        }

        return $next($message);
    }
}
